<?php
/**
 * @version        $Id: edit_fullinfo.php 1 8:38 2010年7月9日Z tianya $
 * @package        DedeCMS.Member
 * @copyright      Copyright (c) 2007 - 2010, DesDev, Inc.
 * @license        http://help.dedecms.com/usersguide/license.html
 * @link           http://www.dedecms.com
 */
require_once(dirname(__FILE__).'/config.php');
require_once DEDEINC.'/membermodel.cls.php';
require_once(DEDEINC."/userlogin.class.php");
CheckRank(0,0);
require_once(DEDEINC.'/enums.func.php');
$menutype = 'config';
$menutype_son = 'edit_fullinfo';
if(!isset($dopost)) $dopost = '';

$user = $dsql->GetOne("SELECT * FROM #@__member WHERE mid='{$cfg_ml->M_ID}'");
$m = $dsql->GetOne("SELECT * FROM #@__member_person WHERE mid='{$cfg_ml->M_ID}'");


if($dopost=='')
{
    $dede_fields = empty($dede_fields) ? '' : trim($dede_fields);
    if(!empty($dede_fields))
    {
        if($dede_fieldshash != md5($dede_fields.$cfg_cookie_encode))
        {
            showMsg('数据校验不对，程序返回', '-1');
            exit();
        }
    }
    
    $dede_fieldshash = empty($dede_fieldshash) ? '' : trim($dede_fieldshash);
    $membermodel = new membermodel($cfg_ml->M_MbType);
    $modelform = $dsql->GetOne("SELECT * FROM #@__member_model WHERE id='$membermodel->modid' ");
    if(!is_array($modelform))
    {
        showmsg('模型表单不存在', '-1');
        exit();
    }
    
	$row = $dsql->GetOne("SELECT * FROM ".$modelform['table']." WHERE mid={$cfg_ml->M_ID}");
    if(!is_array($row))
    {
        showmsg("你访问的记录不存在或未经审核", '-1');
        exit();
    }
    $postform = $membermodel->getForm('edit', $row, 'membermodel');
    include(DEDEMEMBER."/templets/edit_fullinfo.htm");
    exit();
}
/*------------------------
function __Save()
------------------------*/
if($dopost=='save'){
    
        if($qq == ''){
			showMsg('QQ不能为空', '-1');
            exit();
		}else if($mobile == ''){
			showMsg('手机不能为空', '-1');
            exit();
		}else if($email == ''){			
		    showMsg('邮箱不能为空', '-1');            
			exit();		
			}
		//更新主表
        $query = "UPDATE `#@__member_person` SET qq='$qq', mobile='$mobile', email='$email', sex='$sex', uptime='".time()."' WHERE mid='{$cfg_ml->M_ID}'";
		
		//更新实名认证表
		$dsql->ExecuteNoneQuery("UPDATE `#@__member_certification` SET uqq='$qq', utel='$mobile',email='$email', sex='$sex', uptime='".time()."' WHERE mid='{$cfg_ml->M_ID}' ");
		
		//更新主表
		$dsql->ExecuteNoneQuery("UPDATE `#@__member` SET email='$email', uptime='".time()."' WHERE mid='{$cfg_ml->M_ID}' ");
		
        // 清除缓存
        $cfg_ml->DelCache($cfg_ml->M_ID);
        
        if(!$dsql->ExecuteNoneQuery($query))
        {
            ShowMsg("更新主表时出错，请联系管理员！","-1");
            exit();
        }else{
            ShowMsg('成功更新你的详细资料！','edit_fullinfo.php');
			//header("Location:edit_fullinfo.php");
            exit();
        }
}